﻿@model Nullable<System.DateTime>
@if ( Model.HasValue ) {
   @Html.TextBox( "" , String.Format( "{0:yyyy-MM-dd}" , Model.Value ) , new { @class = "textbox" , @style = "width:400px;" } )
}
else {
   @Html.TextBox( "" , String.Format( "{0:yyyy-MM-dd}" , string.Empty ) , new { @class = "textbox" , @style = "width:400px;" } )
}

@{
string name = ViewData.TemplateInfo.HtmlFieldPrefix;
string id = name.Replace( ".", "_" );
}
<script type="text/javascript">
    $(document).ready(function () {
        $("#@id").datepicker
            ({
                dateFormat: 'yy-mm-dd',
                showStatus: true,
                numberOfMonths: 1,
                showAnim: "scale",
                showOptions: {
                    origin: ["top", "left"]
                }
            });

            $("#@id").datepicker($.datepicker.regional["es"]);
    });
</script>